home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / coding / dsp / c5xug.exe / IIR_N.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-06-04  |  1.4 KB  |  50 lines

  1. ;**************************************************************
  2. ;  
  3. ;                 iir_n.asm
  4. ;  
  5. ;                 staff
  6. ;  
  7. ;                 06-04-91
  8. ;  
  9. ;           (C) Texas Instruments Inc., 1992 
  10. ;  
  11. ;           Refer to the file 'license.txt' included with this 
  12. ;           this package for usage and license information. 
  13. ;  
  14. ;**************************************************************
  15.  
  16.     .title "Nth Order IIR Type II Filter"
  17.     .mmregs
  18.  
  19. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  20. ; This routine implements an N-th order type II IIR filter.
  21. ;    d(n) = x(n) + d(n-1)a1 + d(n-2)a2 +...+ d(n-N+1)aN-1
  22. ;    y(n) = d(n)b0 + (dn-1)b1 +...+ d(n-N+1)bN-1
  23. ; Memory Requirement:
  24. ;   State variables (low to high data memery):
  25. ;    d(n) d(n-1) ... d(n-N+1)
  26. ;   Coefficient (low to high program memory):
  27. ;    a(N-1) a(N-2) ... a(1) b(N-1) b(N-2) ... b(1) b(0)
  28. ; Entry Conditions:
  29. ;    AR0 -> Input
  30. ;    AR1 -> d(n-N+1)
  31. ;    AR2 -> Output
  32. ;    BMAR -> a(N-1)
  33. ;    ARP  =    AR0
  34. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  35.  
  36. IIR_N:    ZPR
  37.     LACC    *,15,AR1    ;Get Q15 input
  38.     RPT    #(N-2)        ;for i=1,i<=N-1,++i
  39.     MADS    *-        ;Acc+=a(N-i))*d(n-N+i)
  40.     APAC            ;Final accumulation
  41.     SACH    *,1        ;Save d(n)
  42.     ADRK    N-1        ;AR1 -> d(n-N+1)
  43.     LAMM    BMAR        ;Acc -> a(N-1)
  44.     ADD    #N-1        ;Acc -> b(N-1)
  45.     SAMM    BMAR        ;BMAR -> b(N-1)
  46.     RPTZ    #(N-1)        ;for i=1,i<=N,++i
  47.     MADD    *-        ;Acc+=b(N-i)*d(n-N+i)
  48.     LTA    *,AR2        ;Final accumulation
  49.     SACH    *,1        ;Save Yn
  50.